//
//  XSBaseTableViewController.swift
//  SwiftProject
//
//  Created by 杨晓生 on 16/8/3.
//  Copyright © 2016年 XS. All rights reserved.
//

import UIKit

class XSBaseTableViewController: UITableViewController,XSVisitorViewDelegate {
    
    // 定义变量保存用户是否登录
    var login:Bool = true
    var visitorView : XSVisitorView?
    
    override func loadView() {
        // 如果已经登录创建TableView, 如果没有登录创建访客视图
        login ? super.loadView() : setupVisitor()
    }
    
    /**
     创建访客视图
     */
    private func setupVisitor(){
        
        // 1.创建访客视图
        visitorView = XSVisitorView()
        visitorView?.delegate = self
        self.view = visitorView
        
        //2设置状态栏
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewLogin")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewRegister")
    }
    
    func visitorViewRegister() {
        print(__FUNCTION__)

    }
    
    func visitorViewLogin() {
        print(__FUNCTION__)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false

        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem()
    }

    
}
